package com.hjxr.sysadmin.zsj.controller;

import com.hjxr.framework.aspectj.lang.annotation.Log;
import com.hjxr.framework.aspectj.lang.enums.BusinessType;
import com.hjxr.framework.web.domain.AjaxResult;
import com.hjxr.sysadmin.uitl.poi.ExcelUtil;
import com.hjxr.sysadmin.web.controller.BaseController;
import com.hjxr.sysadmin.web.page.TableDataInfo;
import com.hjxr.sysadmin.zsj.domain.Pagephoto;
import com.hjxr.sysadmin.zsj.service.IPagephotoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 页面图片Controller
 *
 * @author ruoyi
 * @date 2021-03-09
 */
@Api("页面图片信息管理")
@RestController
@RequestMapping("/pagephoto")
public class PagephotoController extends BaseController
{
    @Autowired
    private IPagephotoService pagephotoService;

    /**
     * 查询页面图片列表
     */
    @ApiOperation("查询页面图片列表")
    //@PreAuthorize("@ss.hasPermi('pagephoto:list')")
    @GetMapping("/list")
    public TableDataInfo list(Pagephoto pagephoto)
    {
        startPage();
        List<Pagephoto> list = pagephotoService.selectPagephotoList(pagephoto);
        return getDataTable(list);
    }

    /**
     * 导出页面图片列表
     */
    @ApiOperation("导出页面图片列表")
    //@PreAuthorize("@ss.hasPermi('pagephoto:export')")
    @Log(title = "导出页面图片", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Pagephoto pagephoto)
    {
        List<Pagephoto> list = pagephotoService.selectPagephotoList(pagephoto);
        ExcelUtil<Pagephoto> util = new ExcelUtil<Pagephoto>(Pagephoto.class);
        return util.exportExcel(list, "pagephoto");
    }

    /**
     * id获取页面图片详细信息
     */
    @ApiOperation("获取页面图片详细信息")
    //@PreAuthorize("@ss.hasPermi('pagephoto:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(pagephotoService.selectPagephotoById(id));
    }

    /**
     * 新增页面图片
     */
    @ApiOperation("新增页面图片")
    //@PreAuthorize("@ss.hasPermi('pagephoto:add')")
    @Log(title = "新增页面图片", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Pagephoto pagephoto)
    {
        return toAjax(pagephotoService.insertPagephoto(pagephoto));
    }

    /**
     * 修改页面图片
     */
    @ApiOperation("修改页面图片")
    //@PreAuthorize("@ss.hasPermi('pagephoto:edit')")
    @Log(title = "修改页面图片", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Pagephoto pagephoto)
    {
        return toAjax(pagephotoService.updatePagephoto(pagephoto));
    }

    /**
     * 删除页面图片
     */
    @ApiOperation("删除页面图片")
    //@PreAuthorize("@ss.hasPermi('pagephoto:remove')")
    @Log(title = "删除页面图片", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(pagephotoService.deletePagephotoByIds(ids));
    }
}

